#!/bin/bash

# compile to bitstream
yosys -p 'synth_ice40' -o $1.json $1.v
nextpnr-ice40 --hx8k --pcf $2.pcf --package ct256 --json $1.json --asc $1.asc
icepack $1.asc $1.bin
#iceprog $1.bin
#icetime -tmd hx8k $1.asc

# pad bitstream till 2MB
dd if=/dev/zero of=image bs=2M count=1
dd if=$1.bin of=image conv=notrunc
